package com.ruoyi.system.service.news.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.ruoyi.system.domain.news.NewsScienceResult;
import com.ruoyi.system.domain.news.query.NewsScienceResultQuery;
import com.ruoyi.system.domain.news.vo.NewsScienceResultVo;
import com.ruoyi.system.domain.news.vo.NewsScienceResultVo;
import com.ruoyi.system.mapper.news.NewsScienceResultMapper;
import com.ruoyi.system.service.news.NewsScienceResultService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class NewsScienceResultServiceImpl extends ServiceImpl<NewsScienceResultMapper, NewsScienceResult>
        implements NewsScienceResultService {

    @Override
//    @DataScope(deptAlias = "t",userAlias = "t")
    public List<NewsScienceResultVo> getNewsScienceResultList(NewsScienceResultQuery newsScienceResultQuery) {
        if (newsScienceResultQuery.getIfPage()) {
            PageHelper.startPage(newsScienceResultQuery.getPageNum(), newsScienceResultQuery.getPageSize());
        }
        List<NewsScienceResultVo> newsScienceResultVoList = baseMapper.getNewsScienceResultList(newsScienceResultQuery);
        if (!newsScienceResultVoList.isEmpty() && newsScienceResultQuery.getId() == null) {
            for (NewsScienceResultVo newsScienceResultVo:newsScienceResultVoList) {
                newsScienceResultVo.setContent(null);
            }
        }
        return newsScienceResultVoList;
    }
}
